<?php
/**
 * @name IndexController
 * @author 6p2b7gaqkyoe4aw\administrator
 * @desc 默认控制器
 * @see http://www.php.net/manual/en/class.yaf-controller-abstract.php
 */
error_reporting(E_ALL^E_NOTICE^E_WARNING);
class GoodsController extends Yaf_Controller_Abstract {

	public function listAction(){
		$info=json_decode(file_get_contents("php://input"),true);
		$id=$info['id'] ? $info['id'] : $_REQUEST['id'];
		$sellerid=$info['sellerid'] ? $info['sellerid'] : $_REQUEST['sellerid'];
		$goods_categoryid=$info['goods_categoryid'] ? $info['goods_categoryid'] : $_REQUEST['goods_categoryid'];
		$name=$info['name'] ? $info['name'] : $_REQUEST['name'];
		$page=$info['page'] ? $info['page'] : $_REQUEST['page'];
		$pagesize=$info['pagesize'] ? $info['pagesize'] : $_REQUEST['pagesize'];
		//$goodsname=$info['goodsname'] ? $info['goodsname'] : $_REQUEST['goodsname'];
		
		$where=" 1=1 ";
		
		if($id){
			$where.=" and id = '$id' ";
		}
		
		if($sellerid){
				
			$where.=" and sellerid = '$sellerid' ";
		}
		
		if($goods_categoryid){
		
			$where.=" and goods_categoryid = '$goods_categoryid' ";
		}
		
		
		
		if($name){
		
			$where.=" and name like '%".$name."%' ";
		}
		
		
		$model = new GoodsModel();
		$list = $model->getList($where,$page,$pagesize);
		echo json_encode($list);
	}
	
	public function getAction(){
	
	}
	
	public function addAction(){
	
	}
	
	public function editAction(){
	
	}
	
	public function delAction(){
	
	}
	
	public function statusAction(){
	
	}
	
	
	public function goodsListAction(){
		
	    $info=json_decode(file_get_contents("php://input"),true);
		$id=$info['id'] ? $info['id'] : $_REQUEST['id'];
		$sellerid=$info['sellerid'] ? $info['sellerid'] : $_REQUEST['sellerid'];
		$goods_categoryid=$info['goods_categoryid'] ? $info['goods_categoryid'] : $_REQUEST['goods_categoryid'];
		$name=$info['name'] ? $info['name'] : $_REQUEST['name'];
		$page=$info['page'] ? $info['page'] : $_REQUEST['page'];
		$pagesize=$info['pagesize'] ? $info['pagesize'] : $_REQUEST['pagesize'];
		//$goodsname=$info['goodsname'] ? $info['goodsname'] : $_REQUEST['goodsname'];
		
		$where=" 1=1 ";
		
		if($id){
			$where.=" and id = '$id' ";
		}
		
		if($sellerid){
			
			$where.=" and sellerid = '$sellerid' ";
		}
		
		if($goods_categoryid){
				
			$where.=" and goods_categoryid = '$goods_categoryid' ";
		}
		
		
		
		if($name){
		
			$where.=" and name like '%".$name."%' ";
		}
		
		
		$model = new GoodsModel();
		$list = $model->getList($where,$page,$pagesize);
		exit(json_encode($list));
	}
	
	
	
}
